<?php
$q=$_GET["q"];
$hint='';
if($q!="")
{
include_once ("../Login/databaseconnection.php");
require_once ("../Login/config.php");
$id=$q;
$hint="<br/><font color='black'>";

$resultpp= mysql_query("SELECT * FROM exam Where Exam_Name='$id'");
if($rowpp = mysql_fetch_array($resultpp))
{
$hint=$hint."<br/>To view all <a href='".$basedir."/Exams/searchexam.php?action=exam&e=".$id."' class='searchlinks'>".$q."</a> Exams' details<br/>";
}
$resultds = mysql_query("SELECT DISTINCT(School_Id) FROM exam Where Exam_Name='$id'");
while($rowds= mysql_fetch_array($resultds))
{
$Sc=$rowds['School_Id'];
$hint=$hint."<br/>To view all ".$q." Exams' details of ";
$hint=$hint.'<a href="'.$basedir.'/Exams/searchexam.php?action=school&s='.$rowds['School_Id'].'&e='.$id.'" class="searchlinks">';
$resultsc = mysql_query("SELECT * FROM school Where School_Id='$Sc'");
if(mysql_num_rows($resultsc)==0)
{
$hint=$hint.$Sc;
}
if(mysql_num_rows($resultsc)>0)
{
if($rowsc= mysql_fetch_array($resultsc))
{
$hint=$hint.$rowsc['Name'].' in '.$rowsc['Address'];
}
}
$hint=$hint.'</a><br/>';
}
$resultdy = mysql_query("SELECT DISTINCT(Year) FROM exam Where Exam_Name='$id'");
while($rowdy= mysql_fetch_array($resultdy))
{
$hint=$hint."<br/>To view all ".$q." Exams' details on ";
$hint=$hint.'<a href="'.$basedir.'/Exams/searchexam.php?action=year&y='.$rowdy['Year'].'&e='.$id.'" class="searchlinks">'.$rowdy['Year'].'</a><br/>';
}
$resultds = mysql_query("SELECT DISTINCT(Subject) FROM exam Where Exam_Name='$id'");
while($rowds= mysql_fetch_array($resultds))
{
$hint=$hint."<br/>To view all ".$q." Exams' details of ";
$hint=$hint.'<a href="'.$basedir.'/Exams/searchexam.php?action=subject&su='.$rowds['Subject'].'&e='.$id.'" class="searchlinks">'.$rowds['Subject'].'</a><br/>';
}
$hint=$hint.'</font>';
}
if($hint==''||$hint=="<br/><font color='black'>")
{
echo $hint."<br/>";
$response='<font class="err"><img src="../images/alert.jpg" width="12" height="12"/> There are no results found for this Exam!</font>';
}
else
{
$response=$hint;
}
echo $response;
?>